package com.holly.unit.bpmn.designer.model;

import cn.hutool.core.collection.ListUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.List;
import java.util.Objects;

/**
 * 类描述: 根节点属性值 也就是流程中开始节点属性值
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/5/12 9:59
 */
@Getter
@Setter
@Accessors(chain = true)
public class RootProperties {

    private String title;

    private String initiator;

    /**表单字段控制*/
    private List<FormColControl> formColControls;

    /**流程办理按钮控制 */
    private List<BtnControl> btnControls;

    public static Builder builder(){
        return new Builder();
    }

    public static class Builder{
        private RootProperties properties;

        private Builder() {
            this.properties = new RootProperties();
        }

        public Builder title(final String title) {
            if (Objects.nonNull(title)) {
                this.properties.setTitle(title);
            }
            return this;
        }

        public Builder initiator(final String initiator) {
            if (Objects.nonNull(initiator)) {
                this.properties.setInitiator(initiator);
            }
            return this;
        }

        public Builder columns(final List<FormColControl> formColControls) {
            if (Objects.nonNull(formColControls) && formColControls.size()>0) {
                this.properties.setFormColControls(formColControls);
            }
            return this;
        }

        public Builder columns(final FormColControl formColControl) {
            if (Objects.nonNull(formColControl)) {
                this.properties.setFormColControls(ListUtil.of(formColControl));
            }
            return this;
        }

        public Builder btns(final List<BtnControl> btnControls) {
            if (Objects.nonNull(btnControls) && btnControls.size()>0) {
                this.properties.setBtnControls(btnControls);
            }
            return this;
        }

        public Builder btns(final BtnControl btnControl) {
            if (Objects.nonNull(btnControl)) {
                this.properties.setBtnControls(ListUtil.of(btnControl));
            }
            return this;
        }

        public RootProperties build() {
            return this.properties;
        }
    }



}
